package com.ouc.eddyAlgorithm.controller;

import com.ouc.common.annotation.Log;
import com.ouc.common.core.controller.BaseController;
import com.ouc.common.core.domain.AjaxResult;
import com.ouc.common.core.page.TableDataInfo;
import com.ouc.common.enums.BusinessType;
import com.ouc.common.utils.poi.ExcelUtil;
import com.ouc.eddyAlgorithm.domain.EddysetVg;
import com.ouc.eddyAlgorithm.service.EddysetVgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;

import java.util.List;
import org.springframework.web.bind.annotation.*;
;

/**
 * vg涡旋临时表Controller
 *
 * @author b504
 * @date 2023-02-16
 */
@Controller
@CrossOrigin
@RequestMapping("/eddyTemp/VgEddyset")
public class EddysetVgController extends BaseController {
  private String prefix = "eddyTemp/VgEddyset";

  @Autowired
  private EddysetVgService eddysetVgService;


  //@RequiresPermissions("system.eddymokuai:VgEddyset:view")
  @GetMapping()
  public String VgEddyset() {
    return prefix + "/VgEddyset";
  }

  /**
   * 查询vg涡旋临时表列表
   */
  //@RequiresPermissions("system.eddymokuai:VgEddyset:list")
  @PostMapping("/list")
  @ResponseBody
  public TableDataInfo list(EddysetVg eddysetVg) {
    startPage();
    List<EddysetVg> list = eddysetVgService.selectEddysetVgList(eddysetVg);
    return getDataTable(list);
  }

  /**
   * 导出vg涡旋临时表列表
   */
  //@RequiresPermissions("system.eddymokuai:VgEddyset:export")
  @Log(title = "vg涡旋临时表", businessType = BusinessType.EXPORT)
  @PostMapping("/export")
  @ResponseBody
  public AjaxResult export(EddysetVg eddysetVg) {
    List<EddysetVg> list = eddysetVgService.selectEddysetVgList(eddysetVg);
    ExcelUtil<EddysetVg> util = new ExcelUtil<EddysetVg>(EddysetVg.class);
    return util.exportExcel(list, "vg涡旋临时表数据");
  }

  /**
   * 新增vg涡旋临时表
   */
  @GetMapping("/add")
  public String add() {
    return prefix + "/add";
  }

  /**
   * 新增保存vg涡旋临时表
   */
  //@RequiresPermissions("system.eddymokuai:VgEddyset:add")
  @Log(title = "vg涡旋临时表", businessType = BusinessType.INSERT)
  @PostMapping("/add")
  @ResponseBody
  public AjaxResult addSave(EddysetVg eddysetVg) {
    return toAjax(eddysetVgService.insertEddysetVg(eddysetVg));
  }

  /**
   * 修改vg涡旋临时表
   */
  //@RequiresPermissions("system.eddymokuai:VgEddyset:edit")
  @GetMapping("/edit/{id}")
  public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
    EddysetVg eddysetVg = eddysetVgService.selectEddysetVgById(id);
    mmap.put("eddysetVg", eddysetVg);
    return prefix + "/edit";
  }

  /**
   * 修改保存vg涡旋临时表
   */
  //@RequiresPermissions("system.eddymokuai:VgEddyset:edit")
  @Log(title = "vg涡旋临时表", businessType = BusinessType.UPDATE)
  @PostMapping("/edit")
  @ResponseBody
  public AjaxResult editSave(EddysetVg eddysetVg) {
    return toAjax(eddysetVgService.updateEddysetVg(eddysetVg));
  }

  /**
   * 删除vg涡旋临时表
   */
  //@RequiresPermissions("system.eddymokuai:VgEddyset:remove")
  @Log(title = "vg涡旋临时表", businessType = BusinessType.DELETE)
  @PostMapping("/remove")
  @ResponseBody
  public AjaxResult remove(String ids) {
    return toAjax(eddysetVgService.deleteEddysetVgByIds(ids));
  }


  /**
   * 清空涡旋临时表
   *
   * @return
   */
  @Log(title = "eddySetVg", businessType = BusinessType.CLEAN)
  @RequestMapping("/cleanAll")
  @ResponseBody
  public AjaxResult cleanAll() {
    eddysetVgService.truncateTable();
    return AjaxResult.success("成功清空数据");
  }
}
